package de.se.ludoapp.activity;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import de.se.ludoapp.LudoApplication;
import de.se.ludoapp.R;
import de.se.ludoapp.activity.task.HighscoreTask;

public class HighscoreActivity extends Activity {

	private LudoApplication ludoApp;

	private Handler handler;

	private Runnable runnable;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Initialise Stub LudoServer
		ludoApp = (LudoApplication) this.getApplication();

		// View
		setContentView(R.layout.highscore);

		// update highscore delay 3 sek
		handler = new Handler();
		runnable = new Runnable() {
			public void run() {
				// update highscore
				new HighscoreTask(ludoApp, HighscoreActivity.this).execute();
				handler.postDelayed(this, 3000);
			}
		};
		handler.postDelayed(runnable, 100);
	}

	@Override
	protected void onPause() {
		super.onPause();
		handler.removeCallbacks(runnable);
	}
}
